#ifndef __COMMUNICATE_WITH_LONG_SERVER__
#define __COMMUNICATE_WITH_LONG_SERVER__

#include "iotgo_platformAPI.h"


/* macro: error*/
#define LSERVER_ERROR_NONE          0
#define LSERVER_ERROR_NOT_FINISHED -1
#define LSERVER_ERROR_INIT         -2
#define LSERVER_ERROR_CONNECT      -3
#define LSERVER_ERROR_WEBSOCKET    -4
#define LSERVER_ERROR_COMMUNICATE  -5

/* macro: communicate pace state with long server */
#define LSERVER_IS_NOT_STARTED    -1
#define LSERVER_HAS_INITED         1
#define LSERVER_SOCKET_IS_READY    2
#define LSERVER_WEBSOCKET_IS_READY 3
#define LSERVER_REGISTER_IS_READY  4

/* macro: data type */
#define LSERVER_DATA_TYPE_UPDATE         1
#define LSERVER_DATA_TYPE_UPGRADE        2
#define LSERVER_DATA_TYPE_QUERY_DATE     3
#define LSERVER_DATA_TYPE_QUERY_PARAMS   4

extern int communicateWithLongServer(void);
extern int cleanWithLongServer(void);
extern int getStateWithLongServer(void);

//extern int writeToServer(uint8_t *buf);
extern int writeErrorNumToServer(uint32_t num,uint8_t *sequence);
extern int writeUpdateToServer(uint8_t *params);
extern int writeQueryToServer(uint8_t *params);
extern int writeDateQueryToServer(void);

//extern int availableFromServer(uint8_t type);
//extern int readFromServer(uint8_t *buf,int32_t len);
extern int readFromServerByIotgoType(uint8_t type, uint8_t *sequence, uint8_t *params);

extern int getUserApiKey(uint8_t *u_apikey);
#endif
